package demo2;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/*
DAO:数据访问对象
data access object
 */
@Component
@PropertySource("classpath:config.properties")
public class UserDAO {
    /*
    连接数据库的三个信息：数据库的地，数据库的用户名，数据库的密码
     */
   // @Value("jdbc:.....")
    @Value("${spring.datasource.url}")
    private  String url;
   // @Value("root")
    @Value("${spring.datasource.username}")
    private  String username;
   // @Value("root")
    @Value("${spring.datasource.password}")
    private String password;

    @Override
    public String toString() {
        return "UserDAO{" +
                "url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
